﻿#ifndef __SS_MSG_THREAD_H__
#define __SS_MSG_THREAD_H__
#include "../message/ssMsgIdDef.h"
#include "./threadLock/ssThreadCondition.h"
#include "ssThreadBase.h"
#include "../container/ssList.h"


namespace StarSeeker
{

class ssMsgThread : public ssThreadBase
{
public:
	ssMsgThread();
	virtual ~ssMsgThread();
	//向县城传递消息
	bool PostMsg(ssMsg_s &m);
	bool PostMsg(u32 msgID, u32 subID, ulint param1, ulint param2, ulint param3);
	//停止线程
	void ExitThread();
	//最大缓存数
	void SetMaxMsgCount(u32 ct);
	//当前任务个数
	Byte8_u GetMsgCount();
	//任务链表最大个数
	Byte8_u GetMsgMaxCount();
protected:
	virtual void ThreadMemberFunc();
	//消息处理
	virtual void HandleMessage(ssMsg_s &m) { return; }
	//线程启动时调用
	virtual void OnThreadRun() {}
	//线程退出时调用
	virtual void OnThreadExit() {}

protected:
	ssThreadLock		m_mutex;		//互斥量，配合条件变量使用
	//ssThreadCondition	m_condPut;		//写入条件变量
	ssThreadCondition	m_condGet;		//读取条件变量

	u32					m_maxMsgCount;	//最大缓存消息数,默认100000
	ssList<ssMsg_s>		m_msgList[2];	//消息链表
	u8					m_msgOffset;
};

}
#endif
